/**
 * Created by Elsa on 2017/8/29.
 */
layui.define(['form','jquery'], function(exports){
    var form = layui.form(),
        $ = layui.jquery,
        layer = layui.layer;

    var rgstnum = getQueryString("rgstnum");
    console.log(rgstnum);

    $.ajax({
        type:"GET",
        url:contextPath+"/project/ops/ct/"+ rgstnum ,
        contentType: "application/json; charset=utf-8",
        dataType:"json",
        success:function (data) {
            console.log(data);
            $('input[name="shipname"]').attr("value",data.shipname);
            $('input[name="rgstnum"]').attr("value",data.rgstnum);

            if(data.ctdate){
                $('input[name="ctname"]').attr("value",data.ctname);
                $('input[name="ctdate"]').attr("value",data.ctdate);

                $('#span1').html(data.ctt1jg);
                $('input[name="ctt1jg"][value="'+data.ctt1jg+'"]').attr("checked",true);
                $('#span1x').html(data.ctt1bz);
                $('input[name="re1"]').attr("value",data.ctt1bz);

                $('#span2').html(data.ctt2jg);
                $('input[name="ctt2jg"][value="'+data.ctt2jg+'"]').attr("checked",true);
                $('#span2x').html(data.ctt2bz);
                $('input[name="re2"]').attr("value",data.ctt2bz);

                $('#span3').html(data.ctt3jg);
                $('input[name="ctt3jg"][value="'+data.ctt3jg+'"]').attr("checked",true);
                $('#span3x').html(data.ctt3bz);
                $('input[name="re3"]').attr("value",data.ctt3bz);

                $('#span4').html(data.ctt4jg);
                $('input[name="ctt4jg"][value="'+data.ctt4jg+'"]').attr("checked",true);
                $('#span4x').html(data.ctt4bz);
                $('input[name="re4"]').attr("value",data.ctt4bz);

                $('#span5').html(data.ctt5jg);
                $('input[name="ctt5jg"][value="'+data.ctt5jg+'"]').attr("checked",true);
                $('#span5x').html(data.ctt5bz);
                $('input[name="re5"]').attr("value",data.ctt5bz);

                $('#span6').html(data.ctt6jg);
                $('input[name="ctt6jg"][value="'+data.ctt6jg+'"]').attr("checked",true);
                $('#span6x').html(data.ctt6bz);
                $('input[name="re6"]').attr("value",data.ctt6bz);

                $('#span7').html(data.ctt7jg);
                $('input[name="ctt7jg"][value="'+data.ctt7jg+'"]').attr("checked",true);
                $('#span7x').html(data.ctt7bz);
                $('input[name="re7"]').attr("value",data.ctt7bz);

                $('#span8').html(data.ctt8jg);
                $('input[name="ctt8jg"][value="'+data.ctt8jg+'"]').attr("checked",true);
                $('#span8x').html(data.ctt8bz);
                $('input[name="re8"]').attr("value",data.ctt8bz);

                $('#span9').html(data.ctt9jg);
                $('input[name="ctt9jg"][value="'+data.ctt9jg+'"]').attr("checked",true);
                $('#span9x').html(data.ctt9bz);
                $('input[name="re9"]').attr("value",data.ctt9bz);

                $('#span10').html(data.ctt10jg);
                $('input[name="ctt10jg"][value="'+data.ctt10jg+'"]').attr("checked",true);
                $('#span10x').html(data.ctt10bz);
                $('input[name="re10"]').attr("value",data.ctt10bz);

                $('#span11').html(data.ctt11jg);
                $('input[name="ctt11jg"][value="'+data.ctt11jg+'"]').attr("checked",true);
                $('#span11x').html(data.ctt11bz);
                $('input[name="re11"]').attr("value",data.ctt11bz);

                $('#sus').show();
                $('#su').on('click',function () {
                    window.open('../../../../print/opera/ExperRecord/ct/OperaCtRecord.html?rgstnum='+rgstnum);
                });
            }else{
                
            }
            form.render();

        },
        error:function (e) {

        }
    });

    //自定义验证规则
    form.verify({
        title: function(value) {
            if(value.length < 5) {
                return '标题至少得5个字符啊';
            }
        },
        pass: [/(.+){6,12}$/, '密码必须6到12位'],
        content: function(value) {
            layedit.sync(editIndex);
        }
    });

    exports('OperaCtRecord', {}); //注意，这里是模块输出的核心，模块名必须和use时的模块名一致
});